package com.zg.common.core.dao.apis.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.common.core.dao.apis.entity.ApiService;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author Zxb
 */
@Mapper
public interface ApiServiceMapper extends BaseMapper<ApiService> {

    @Select("<script>" +
            "SELECT service.*, project.project_name FROM api_service service " +
            "LEFT JOIN api_project project ON project.id = service.project_id " +
            "<where>" +
            "  service.is_del = 0" +
            "  <if test=\"ew != null and ew.sqlSegment != ''\"> AND ${ew.sqlSegment}</if>" +
            "</where>" +
            "</script>")
    Page<ApiService> page(Page<ApiService> page,
                          @Param(Constants.WRAPPER) LambdaQueryWrapper<ApiService> wrapper);
}
